package com.lanou.sinasports.activity;

import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.MediaController;
import android.widget.VideoView;

import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;

import com.android.volley.toolbox.Volley;
import com.lanou.sinasports.R;
import com.lanou.sinasports.beans.GsonNbaDec;
import com.lanou.sinasports.utils.GsonRequest;

/**
 * Created by dllo on 16/1/25.
 */
public class NbaDecActivity extends AppCompatActivity {
    private RequestQueue queue;
    private String url="";
    private WebView webView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_nba_dec);
        Intent intent=getIntent();
        String playlink=intent.getStringExtra("playlink");
        String vid=intent.getStringExtra("vid");

        Log.d("+++++_____", playlink);

        url="http://platform.sina.com.cn/sports_client/related_video?app_key=2586208540&num=5&video_id="+
               vid+"&pcurl="+playlink;
        Log.d("???????????", url);
        queue= Volley.newRequestQueue(this);

       webView= (WebView) findViewById(R.id.webview);
        WebSettings settings =webView.getSettings();
        settings.setDomStorageEnabled(true);
        settings.setJavaScriptEnabled(true);
        settings.setAllowFileAccess(true);
       webView.loadUrl(playlink);

//        GsonRequest<GsonNbaDec> request=new GsonRequest<GsonNbaDec>(url, GsonNbaDec.class, new Response.Listener<GsonNbaDec>() {
//            @Override
//            public void onResponse(GsonNbaDec gsonNbaDec) {
//
//                    String videoUrl=gsonNbaDec.getResult().getData().get(0).getEmbed_swf();
//                Log.d("+++++++======", videoUrl);
//
//                    loadFlash(videoUrl);
//
//            }
//        }, new Response.ErrorListener() {
//            @Override
//            public void onErrorResponse(VolleyError error) {
//
//            }
//        });
//
//        queue.add(request);
    }

//    public void loadFlash(String uri) {
//        WebView mWebFlash = (WebView) findViewById(R.id.webview);
//        WebSettings settings = mWebFlash.getSettings();
//
//        settings.setJavaScriptEnabled(true);
//        settings.setAllowFileAccess(true);
//        settings.setDefaultTextEncodingName("GBK");
//        mWebFlash.setBackgroundColor(0);
//        mWebFlash.loadUrl(uri);
//    }
}
